Skip to content

IconLabel

Base classes

Name Children Inherits
Widget
prettyqt.widgets.widget
The base class of all user interface objects.

⋔ Inheritance diagram

graph TD
  2719850305["custom_widgets.IconLabel"]
  3664736470["widgets.Widget"]
  829357528["widgets.WidgetMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  625385617["gui.PaintDeviceMixin"]
  3620195106["QtWidgets.QWidget"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  673956333["QtGui.QPaintDevice"]
  3664736470 --> 2719850305
  829357528 --> 3664736470
  3227531497 --> 829357528
  2751680898 --> 3227531497
  625385617 --> 829357528
  2751680898 --> 625385617
  2751680898 --> 829357528
  3620195106 --> 3664736470
  3984060476 --> 3620195106
  37984305 --> 3984060476
  2751680898 --> 37984305
  673956333 --> 3620195106
  37984305 --> 673956333

🛈 DocStrings

Bases: Widget

Source code in prettyqt/custom_widgets/labels/iconlabel.py
class IconLabel(widgets.Widget):
    def __init__(
        self,
        text: str | None = None,
        tooltip: str = "",
        icon: datatypes.IconType = "mdi.help-circle-outline",
        parent: widgets.QWidget | None = None,
    ):
        super().__init__(parent=parent)
        layout = self.set_layout("horizontal", spacing=0)
        self.label = widgets.Label(text, margin=10)
        self.label.set_size_policy(horizontal="minimum")
        icon = iconprovider.get_icon(icon)
        self.icon = widgets.Label(tool_tip=tooltip, pixmap=icon.pixmap(20, 20))
        self.icon.set_size_policy(horizontal="minimum")
        layout.add(self.label)
        layout.add(self.icon)
        layout.addStretch()

    def __getattr__(self, value: str):
        return self.label.__getattribute__(value)

    def __repr__(self):
        return get_repr(self, self.text())

:fa-brands-github: Show source on GitHub